package com.itheima;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;

/**
 * @ProjectName: shixun DaErXia
 * @Titile: MapDemo
 * @Author: 雨
 * @Description: TODO
 */
public class MapDemo {
    public static void main(String[] args) {
        test1();

    }
    public static void test3(){
        Map<String,Double>map=new HashMap<>();
        map.put("zhansgan",100.0);
        map.put("lisi",200.0);
        map.put("wangwu",300.0);
        map.put("zhaoliu",400.0);

        map.forEach(new BiConsumer<String, Double>() {
            @Override
            public void accept(String key, Double value) {
                System.out.println(key+"---"+ value);
            }
        });
        map.forEach((key, value) -> System.out.println(key + "---" + value));
    }
    public static void test2(){
        Map<String,Double>map=new HashMap<>();
        map.put("zhansgan",100.0);
        map.put("lisi",200.0);
        map.put("wangwu",300.0);
        map.put("zhaoliu",400.0);
        //1.将map集合转成set集合（将map中key-value绑定成一个对象的entry）
        Set<Map.Entry<String,Double>> entrySet=map.entrySet();
        for (Map.Entry<String,Double>entry:entrySet){
            String key=entry.getKey();
            Double value=entry.getValue();
            System.out.println(key+"---"+value);
        }

    }

    public static void test1() {
        Map<String,Double>map=new HashMap<>();
        map.put("zhansgan",100.0);
        map.put("lisi",200.0);
        map.put("wangwu",300.0);
        map.put("zhaoliu",400.0);
        Set<String> keySet=new HashSet<>();
        for (String key:keySet){
            Double value=map.get(key);
            System.out.println(key+"---"+value);
        }
    }

    public static void test0() {
        Map<String,Double>map=new HashMap<>();
        boolean empty= map.isEmpty();
        System.out.println(map);
        boolean containsValue=map.containsValue(200.0);
        System.out.println(map+"---"+map);

        boolean containsKey=map.containsKey(200.0);
        System.out.println(map+"---"+map);
        int size= map.size();
        System.out.println(map);
    }
}
